.class public Lrexsee/core/transportation/RexseeDownload;
.super Ljava/lang/Object;
.source "RexseeDownload.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;
    }
.end annotation


# static fields
.field public static final DOWNLOAD_DIRECTORY:Ljava/lang/String; = "download"

.field public static final DOWNLOAD_PROGRESS_CONNECTING:I = -0x1

.field public static final DOWNLOAD_PROGRESS_DONE:I = 0x1

.field public static final DOWNLOAD_PROGRESS_EXCEPTION:I = -0x3

.field public static final DOWNLOAD_PROGRESS_ONGOING:I = 0x0

.field public static final DOWNLOAD_PROGRESS_TIMEOUT:I = -0x2

.field public static final EVENT_ONDOWNLOADFINISHEDED:Ljava/lang/String; = "onDownloadFinished"

.field public static final EVENT_ONDOWNLOADPROGRESSCHANGED:Ljava/lang/String; = "onDownloadProgressChanged"

.field public static final EVENT_ONDOWNLOADTIMEOUT:Ljava/lang/String; = "onDownloadTimeout"

.field public static final INTERFACE_NAME:Ljava/lang/String; = "Download"


# instance fields
.field protected final mBrowser:Lrexsee/core/browser/Browser;

.field protected final mContext:Landroid/content/Context;

.field private syncDownloadProgress:Ljava/lang/String;


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 2
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 59
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 52
    const/4 v0, 0x0

    iput-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->syncDownloadProgress:Ljava/lang/String;

    .line 60
    iput-object p1, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    .line 61
    invoke-virtual {p1}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->mContext:Landroid/content/Context;

    .line 62
    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onDownloadProgressChanged"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 63
    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onDownloadFinished"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 64
    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    const-string v1, "onDownloadTimeout"

    invoke-virtual {v0, v1}, Lrexsee/core/browser/clazz/EventList;->add(Ljava/lang/String;)V

    .line 65
    return-void
.end method

.method static synthetic access$0(Lrexsee/core/transportation/RexseeDownload;Ljava/lang/String;)Ljava/io/File;
    .locals 1

    .prologue
    .line 85
    invoke-direct {p0, p1}, Lrexsee/core/transportation/RexseeDownload;->getDownloadFile(Ljava/lang/String;)Ljava/io/File;

    move-result-object v0

    return-object v0
.end method

.method static synthetic access$1(Lrexsee/core/transportation/RexseeDownload;Ljava/lang/String;)V
    .locals 0

    .prologue
    .line 52
    iput-object p1, p0, Lrexsee/core/transportation/RexseeDownload;->syncDownloadProgress:Ljava/lang/String;

    return-void
.end method

.method private getDownloadFile(Ljava/lang/String;)Ljava/io/File;
    .locals 10
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    const/4 v9, 0x0

    .line 86
    if-nez p1, :cond_0

    .line 87
    iget-object v5, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v6

    const-string v7, "Invalid path."

    invoke-virtual {v5, v6, v7}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v5, v9

    .line 111
    :goto_0
    return-object v5

    .line 90
    :cond_0
    invoke-static {p1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v3

    .line 91
    .local v3, "downloadPathUri":Landroid/net/Uri;
    invoke-virtual {v3}, Landroid/net/Uri;->getScheme()Ljava/lang/String;

    move-result-object v2

    .line 92
    .local v2, "downloadPathScheme":Ljava/lang/String;
    if-eqz v2, :cond_1

    const-string v5, "file"

    invoke-virtual {v2, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-nez v5, :cond_2

    .line 93
    :cond_1
    iget-object v5, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v6

    new-instance v7, Ljava/lang/StringBuilder;

    const-string v8, "Invalid path scheme: "

    invoke-direct {v7, v8}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v7, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v5, v6, v7}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v5, v9

    .line 94
    goto :goto_0

    .line 96
    :cond_2
    new-instance v1, Ljava/io/File;

    invoke-virtual {v3}, Landroid/net/Uri;->getSchemeSpecificPart()Ljava/lang/String;

    move-result-object v5

    invoke-direct {v1, v5}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 97
    .local v1, "downloadPathFile":Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v5

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v6

    invoke-virtual {v6}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_3

    .line 98
    const-string v5, "mounted"

    invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-nez v5, :cond_3

    .line 99
    iget-object v5, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v6

    const-string v7, "SD card is not ready."

    invoke-virtual {v5, v6, v7}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v5, v9

    .line 100
    goto :goto_0

    .line 103
    :cond_3
    invoke-virtual {v1}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v0

    .line 105
    .local v0, "downloadPathDir":Ljava/io/File;
    :try_start_0
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v5

    if-eqz v5, :cond_4

    invoke-virtual {v0}, Ljava/io/File;->isDirectory()Z

    move-result v5

    if-nez v5, :cond_4

    invoke-virtual {v0}, Ljava/io/File;->delete()Z

    .line 106
    :cond_4
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v5

    if-nez v5, :cond_5

    invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    :cond_5
    move-object v5, v1

    .line 111
    goto :goto_0

    .line 107
    :catch_0
    move-exception v5

    move-object v4, v5

    .line 108
    .local v4, "e":Ljava/lang/Exception;
    iget-object v5, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6, v4}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    move-object v5, v9

    .line 109
    goto/16 :goto_0
.end method

.method private getDownloadURL(Ljava/lang/String;)Ljava/net/URL;
    .locals 7
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    const/4 v6, 0x0

    .line 68
    if-nez p1, :cond_0

    move-object v2, v6

    .line 82
    :goto_0
    return-object v2

    .line 69
    :cond_0
    invoke-static {p1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v2

    invoke-virtual {v2}, Landroid/net/Uri;->getScheme()Ljava/lang/String;

    move-result-object v1

    .line 70
    .local v1, "scheme":Ljava/lang/String;
    if-eqz v1, :cond_1

    const-string v2, "http"

    invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-nez v2, :cond_2

    const-string v2, "https"

    invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-nez v2, :cond_2

    .line 71
    :cond_1
    iget-object v2, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v3

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v5, ":Invalid url scheme!"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v2, v3, v4}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v2, v6

    .line 72
    goto :goto_0

    .line 74
    :cond_2
    iget-object v2, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v2, v2, Lrexsee/core/browser/Browser;->domainWhiteList:Lrexsee/core/browser/clazz/DomainWhiteList;

    invoke-virtual {v2, p1}, Lrexsee/core/browser/clazz/DomainWhiteList;->isValidUrl(Ljava/lang/String;)Z

    move-result v2

    if-nez v2, :cond_3

    .line 75
    iget-object v2, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v3

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v5, ":Url not allowed."

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v2, v3, v4}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v2, v6

    .line 76
    goto :goto_0

    .line 79
    :cond_3
    :try_start_0
    new-instance v2, Ljava/net/URL;

    invoke-direct {v2, p1}, Ljava/net/URL;-><init>(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 80
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 81
    .local v0, "e":Ljava/net/MalformedURLException;
    iget-object v2, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v3

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v5, ":Exception on generating URL."

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v2, v3, v4}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v2, v6

    .line 82
    goto/16 :goto_0
.end method


# virtual methods
.method public download(Ljava/lang/String;)V
    .locals 1
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    .line 307
    const/4 v0, 0x1

    invoke-virtual {p0, p1, v0}, Lrexsee/core/transportation/RexseeDownload;->download(Ljava/lang/String;Z)V

    .line 308
    return-void
.end method

.method public download(Ljava/lang/String;Z)V
    .locals 2
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "cancelable"    # Z

    .prologue
    .line 310
    new-instance v0, Lrexsee/core/transportation/DownloadFile;

    invoke-direct {v0}, Lrexsee/core/transportation/DownloadFile;-><init>()V

    .line 311
    .local v0, "downloadFile":Lrexsee/core/transportation/DownloadFile;
    iget-object v1, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->urlListeners:Lrexsee/core/browser/RexseeUrl;

    invoke-virtual {v1, p1}, Lrexsee/core/browser/RexseeUrl;->getAbsoluteUrl(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    .line 312
    iget-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    invoke-virtual {p0, v1}, Lrexsee/core/transportation/RexseeDownload;->getDefaultDownloadPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->path:Ljava/lang/String;

    .line 313
    new-instance v1, Lrexsee/core/transportation/RexseeDownload$4;

    invoke-direct {v1, p0, p2}, Lrexsee/core/transportation/RexseeDownload$4;-><init>(Lrexsee/core/transportation/RexseeDownload;Z)V

    invoke-virtual {p0, v0, v1}, Lrexsee/core/transportation/RexseeDownload;->download(Lrexsee/core/transportation/DownloadFile;Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;)V

    .line 339
    return-void
.end method

.method public download(Lrexsee/core/transportation/DownloadFile;Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;)V
    .locals 9
    .param p1, "downloadFile"    # Lrexsee/core/transportation/DownloadFile;
    .param p2, "progressListener"    # Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;

    .prologue
    const/4 v3, -0x3

    const/4 v4, 0x0

    const/4 v1, 0x0

    const-string v6, "Download file could not be null."

    .line 115
    if-nez p2, :cond_0

    .line 116
    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v1

    const-string v2, "Progress listener could not be null."

    invoke-virtual {v0, v1, v2}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    .line 216
    :goto_0
    return-void

    .line 119
    :cond_0
    if-nez p1, :cond_1

    .line 120
    const-string v0, "Download file could not be null."

    move-object v0, p2

    move-object v2, v1

    move v5, v4

    move-object v7, v1

    invoke-virtual/range {v0 .. v7}, Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;->run(Ljava/lang/String;Ljava/lang/String;IIILjava/lang/String;Ljava/lang/Runnable;)V

    .line 121
    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v1

    const-string v2, "Download file could not be null."

    invoke-virtual {v0, v1, v6}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0

    .line 124
    :cond_1
    iget-object v0, p1, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    invoke-direct {p0, v0}, Lrexsee/core/transportation/RexseeDownload;->getDownloadURL(Ljava/lang/String;)Ljava/net/URL;

    move-result-object v8

    .line 125
    .local v8, "sourceUrl":Ljava/net/URL;
    if-nez v8, :cond_2

    .line 126
    const-string v6, "Invalid source url."

    move-object v0, p2

    move-object v2, v1

    move v5, v4

    move-object v7, v1

    invoke-virtual/range {v0 .. v7}, Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;->run(Ljava/lang/String;Ljava/lang/String;IIILjava/lang/String;Ljava/lang/Runnable;)V

    goto :goto_0

    .line 129
    :cond_2
    new-instance v0, Lrexsee/core/transportation/RexseeDownload$1;

    invoke-direct {v0, p0, p2, p1, v8}, Lrexsee/core/transportation/RexseeDownload$1;-><init>(Lrexsee/core/transportation/RexseeDownload;Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;Lrexsee/core/transportation/DownloadFile;Ljava/net/URL;)V

    .line 215
    invoke-virtual {v0}, Lrexsee/core/transportation/RexseeDownload$1;->start()V

    goto :goto_0
.end method

.method public downloadAndOpen(Ljava/lang/String;)V
    .locals 2
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    .line 283
    new-instance v0, Lrexsee/core/transportation/DownloadFile;

    invoke-direct {v0}, Lrexsee/core/transportation/DownloadFile;-><init>()V

    .line 284
    .local v0, "downloadFile":Lrexsee/core/transportation/DownloadFile;
    iget-object v1, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->urlListeners:Lrexsee/core/browser/RexseeUrl;

    invoke-virtual {v1, p1}, Lrexsee/core/browser/RexseeUrl;->getAbsoluteUrl(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    .line 285
    iget-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    invoke-virtual {p0, v1}, Lrexsee/core/transportation/RexseeDownload;->getDefaultDownloadPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->path:Ljava/lang/String;

    .line 286
    new-instance v1, Lrexsee/core/transportation/RexseeDownload$3;

    invoke-direct {v1, p0}, Lrexsee/core/transportation/RexseeDownload$3;-><init>(Lrexsee/core/transportation/RexseeDownload;)V

    invoke-virtual {p0, v0, v1}, Lrexsee/core/transportation/RexseeDownload;->download(Lrexsee/core/transportation/DownloadFile;Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;)V

    .line 305
    return-void
.end method

.method public downloadByDefault(Ljava/lang/String;)V
    .locals 1
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    .line 352
    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-static {v0, p1}, Lrexsee/core/utilities/Utilities;->downloadByDefault(Lrexsee/core/browser/Browser;Ljava/lang/String;)V

    .line 353
    return-void
.end method

.method public downloadWithCallback(Ljava/lang/String;)V
    .locals 2
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    .line 341
    new-instance v0, Lrexsee/core/transportation/DownloadFile;

    invoke-direct {v0}, Lrexsee/core/transportation/DownloadFile;-><init>()V

    .line 342
    .local v0, "downloadFile":Lrexsee/core/transportation/DownloadFile;
    iget-object v1, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->urlListeners:Lrexsee/core/browser/RexseeUrl;

    invoke-virtual {v1, p1}, Lrexsee/core/browser/RexseeUrl;->getAbsoluteUrl(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    .line 343
    iget-object v1, v0, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    invoke-virtual {p0, v1}, Lrexsee/core/transportation/RexseeDownload;->getDefaultDownloadPath(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    iput-object v1, v0, Lrexsee/core/transportation/DownloadFile;->path:Ljava/lang/String;

    .line 344
    new-instance v1, Lrexsee/core/transportation/RexseeDownload$5;

    invoke-direct {v1, p0}, Lrexsee/core/transportation/RexseeDownload$5;-><init>(Lrexsee/core/transportation/RexseeDownload;)V

    invoke-virtual {p0, v0, v1}, Lrexsee/core/transportation/RexseeDownload;->download(Lrexsee/core/transportation/DownloadFile;Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;)V

    .line 350
    return-void
.end method

.method public getDefaultDownloadPath(Ljava/lang/String;)Ljava/lang/String;
    .locals 8
    .param p1, "url"    # Ljava/lang/String;

    .prologue
    const/4 v6, 0x0

    const-string v7, ":Error on extracting the file name from the url."

    const-string v5, "_"

    const-string v4, "/"

    .line 269
    const-string v1, "/"

    invoke-virtual {p1, v4}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 270
    iget-object v1, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v2

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v4, ":Error on extracting the file name from the url."

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v2, v3}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v1, v6

    .line 279
    :goto_0
    return-object v1

    .line 273
    :cond_0
    const-string v1, "/"

    invoke-virtual {p1, v4}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I

    move-result v1

    add-int/lit8 v1, v1, 0x1

    invoke-virtual {p1, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v0

    .line 274
    .local v0, "fileName":Ljava/lang/String;
    if-eqz v0, :cond_1

    const-string v1, ""

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_2

    .line 275
    :cond_1
    iget-object v1, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/core/transportation/RexseeDownload;->getInterfaceName()Ljava/lang/String;

    move-result-object v2

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v4, ":Error on extracting the file name from the url."

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v2, v3}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    move-object v1, v6

    .line 276
    goto :goto_0

    .line 278
    :cond_2
    const-string v1, "?"

    const-string v2, "_"

    invoke-virtual {v0, v1, v5}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v1

    const-string v2, "&"

    const-string v3, "_"

    invoke-virtual {v1, v2, v5}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v1

    const-string v2, "="

    const-string v3, "_"

    invoke-virtual {v1, v2, v5}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v1

    const-string v2, " "

    const-string v3, "_"

    invoke-virtual {v1, v2, v5}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v0

    .line 279
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "file://"

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v2

    invoke-virtual {v2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, "/"

    invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, "download"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, "/"

    invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    goto/16 :goto_0
.end method

.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 31
    new-instance v0, Lrexsee/core/transportation/RexseeDownload;

    invoke-direct {v0, p1}, Lrexsee/core/transportation/RexseeDownload;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 27
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "Download"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 35
    new-instance v0, Lrexsee/core/transportation/RexseeDownload;

    invoke-direct {v0, p1}, Lrexsee/core/transportation/RexseeDownload;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public syncDownload(Ljava/util/ArrayList;Z)Ljava/lang/String;
    .locals 5
    .param p2, "cancelable"    # Z
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/ArrayList",
            "<",
            "Lrexsee/core/transportation/DownloadFile;",
            ">;Z)",
            "Ljava/lang/String;"
        }
    .end annotation

    .prologue
    .local p1, "downloadFiles":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Lrexsee/core/transportation/DownloadFile;>;"
    const-string v4, ""

    .line 256
    const/4 v0, 0x0

    .local v0, "i":I
    :goto_0
    invoke-virtual {p1}, Ljava/util/ArrayList;->size()I

    move-result v2

    if-lt v0, v2, :cond_0

    .line 263
    iget-object v2, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v2, v2, Lrexsee/core/browser/Browser;->progressDialog:Lrexsee/core/progress/RexseeProgressDialog;

    invoke-virtual {v2}, Lrexsee/core/progress/RexseeProgressDialog;->hide()V

    .line 264
    const-string v2, ""

    move-object v2, v4

    :goto_1
    return-object v2

    .line 257
    :cond_0
    invoke-virtual {p1, v0}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lrexsee/core/transportation/DownloadFile;

    const/4 v3, 0x0

    invoke-virtual {p0, v2, p2, v3}, Lrexsee/core/transportation/RexseeDownload;->syncDownload(Lrexsee/core/transportation/DownloadFile;ZZ)Ljava/lang/String;

    move-result-object v1

    .line 258
    .local v1, "rtn":Ljava/lang/String;
    const-string v2, ""

    invoke-virtual {v1, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-nez v2, :cond_1

    .line 259
    iget-object v2, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v2, v2, Lrexsee/core/browser/Browser;->progressDialog:Lrexsee/core/progress/RexseeProgressDialog;

    invoke-virtual {v2}, Lrexsee/core/progress/RexseeProgressDialog;->hide()V

    move-object v2, v1

    .line 260
    goto :goto_1

    .line 256
    :cond_1
    add-int/lit8 v0, v0, 0x1

    goto :goto_0
.end method

.method public syncDownload(Lrexsee/core/transportation/DownloadFile;ZZ)Ljava/lang/String;
    .locals 2
    .param p1, "downloadFile"    # Lrexsee/core/transportation/DownloadFile;
    .param p2, "cancelable"    # Z
    .param p3, "hideProgress"    # Z

    .prologue
    .line 218
    const/4 v0, 0x0

    iput-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->syncDownloadProgress:Ljava/lang/String;

    .line 219
    new-instance v0, Lrexsee/core/transportation/RexseeDownload$2;

    invoke-direct {v0, p0, p2}, Lrexsee/core/transportation/RexseeDownload$2;-><init>(Lrexsee/core/transportation/RexseeDownload;Z)V

    invoke-virtual {p0, p1, v0}, Lrexsee/core/transportation/RexseeDownload;->download(Lrexsee/core/transportation/DownloadFile;Lrexsee/core/transportation/RexseeDownload$DownloadProgressListener;)V

    .line 246
    :goto_0
    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->syncDownloadProgress:Ljava/lang/String;

    if-eqz v0, :cond_1

    .line 252
    if-eqz p3, :cond_0

    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->progressDialog:Lrexsee/core/progress/RexseeProgressDialog;

    invoke-virtual {v0}, Lrexsee/core/progress/RexseeProgressDialog;->hide()V

    .line 253
    :cond_0
    iget-object v0, p0, Lrexsee/core/transportation/RexseeDownload;->syncDownloadProgress:Ljava/lang/String;

    return-object v0

    .line 248
    :cond_1
    const-wide/16 v0, 0x64

    :try_start_0
    invoke-static {v0, v1}, Ljava/lang/Thread;->sleep(J)V
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 249
    :catch_0
    move-exception v0

    goto :goto_0
.end method

.method public syncDownloads(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 9
    .param p1, "urls"    # Ljava/lang/String;
    .param p2, "path"    # Ljava/lang/String;

    .prologue
    const-string v8, "/"

    .line 356
    const-string v5, ","

    invoke-virtual {p1, v5}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v4

    .line 357
    .local v4, "urlArr":[Ljava/lang/String;
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    .line 358
    .local v0, "downloadFiles":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Lrexsee/core/transportation/DownloadFile;>;"
    const/4 v2, 0x0

    .local v2, "i":I
    :goto_0
    array-length v5, v4

    if-lt v2, v5, :cond_0

    .line 365
    const/4 v5, 0x1

    invoke-virtual {p0, v0, v5}, Lrexsee/core/transportation/RexseeDownload;->syncDownload(Ljava/util/ArrayList;Z)Ljava/lang/String;

    move-result-object v5

    return-object v5

    .line 359
    :cond_0
    new-instance v1, Lrexsee/core/transportation/DownloadFile;

    invoke-direct {v1}, Lrexsee/core/transportation/DownloadFile;-><init>()V

    .line 360
    .local v1, "file":Lrexsee/core/transportation/DownloadFile;
    iget-object v5, p0, Lrexsee/core/transportation/RexseeDownload;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v5, v5, Lrexsee/core/browser/Browser;->urlListeners:Lrexsee/core/browser/RexseeUrl;

    aget-object v6, v4, v2

    invoke-virtual {v5, v6}, Lrexsee/core/browser/RexseeUrl;->getAbsoluteUrl(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    iput-object v5, v1, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    .line 361
    iget-object v5, v1, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    iget-object v6, v1, Lrexsee/core/transportation/DownloadFile;->url:Ljava/lang/String;

    const-string v7, "/"

    invoke-virtual {v6, v8}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I

    move-result v6

    add-int/lit8 v6, v6, 0x1

    invoke-virtual {v5, v6}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v3

    .line 362
    .local v3, "name":Ljava/lang/String;
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-static {p2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v6

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v6, "/"

    invoke-virtual {v5, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    iput-object v5, v1, Lrexsee/core/transportation/DownloadFile;->path:Ljava/lang/String;

    .line 363
    invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 358
    add-int/lit8 v2, v2, 0x1

    goto :goto_0
.end method
